package com.wish.controller;


import com.wish.util.SMSUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/test")
@Slf4j
public class Test {


    /**
     * appId   请联系销售，或者在页面中 获取
     */
    @Value("${SMS.appId}")
    String appId;

    // 密钥 请联系销售，或者在页面中 获取
    @Value("${SMS.secretKey}")
    String secretKey;

    // 接口地址 请联系销售获取
    @Value("${SMS.host}")
    String host;

    // 加密算法
    @Value("${SMS.algorithm}")
    String algorithm;

    // 编码
    String encode = "UTF-8";

    // 是否压缩
    boolean isGizp = true;

    @RequestMapping("/code")
    public void testCode(){
        log.info(appId+" **** "+secretKey);
        System.out.println(appId+" **** "+secretKey);
        StringBuffer sb = new StringBuffer();
        for(int i = 0; i<6;i++){
            sb.append((int)(Math.random()*10));
        }
        SMSUtil.smsSend(appId,secretKey,host,algorithm,encode,isGizp,sb.toString(),"2","13245931092");
    }
}
